<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/WEB-INF/views/head.jsp"/>
<script>
$(function() {
	$("#sortHead").headSort();
	<shiro:hasPermission name="core:node:edit">
	$("#pagedTable tbody tr").dblclick(function(eventObj) {
		var nodeName = eventObj.target.nodeName.toLowerCase();
		if(nodeName!="input"&&nodeName!="select"&&nodeName!="textarea") {
//			location.href=$("#edit_opt_"+$(this).attr("beanid")).attr('href');
		}
	});
	</shiro:hasPermission>
    if('${init}'=="0"){
     $("#searchForm").submit();
    }
});
function confirmDelete() {
	return confirm("<s:message code='confirmDelete'/>");
}
function optSingle(opt) {
	if(Cms.checkeds("ids")==0) {
		alert("<s:message code='pleaseSelectRecord'/>");
		return false;
	}
	if(Cms.checkeds("ids")>1) {
		alert("<s:message code='pleaseSelectOne'/>");
		return false;
	}
	var id = $("input[name='ids']:checkbox:checked").val();
	location.href=$(opt+id).attr("href");
}
function optMulti(form, url, noValidate) {
	noValidate = noValidate || false;
	if(!noValidate && Cms.checkeds("ids")==0) {
		alert("<s:message code='pleaseSelectRecord'/>");
		return false;
	}
	var ids = "";
	$("input[name='ids']:checkbox:checked").each(function(){
		ids += "&ids="+$(this).val();
	});
	if(ids.length>0) {
		if(url.indexOf("?")==-1) {
			url += "?" + ids.substring(1);
		} else if(url.lastIndexOf("?")==url.length-1||url.lastIndexOf("&")==url.length-1) {
			url += ids.substring(1);
		} else {
			url += ids;
		}		
	}
	location.href=url;
	return true;	
}
function optDelete(form) {
	if(Cms.checkeds("ids")==0) {
		alert("<s:message code='pleaseSelectRecord'/>");
		return false;
	}
	if(!confirmDelete()) {
		return false;
	}
	form.action='nodedelete.do';
	form.submit();
	return true;
}
<c:if test="${!empty refreshLeft}">
parent.frames["left"].location.href="left.do";
</c:if>
//修改发布状态
function  updateNodePublish(nodeId) {
  var publish="";
  var str=$("#"+nodeId).html();
  if(str.trim()=="已发布"){
    publish="1";
  }else if(str.trim()=="未发布"){
    publish="0";
  }
  var data={};
  data.nodeId=nodeId;
  data.publish=publish;
  $.ajax({
    type: "POST",
    url: "/cmscp/core/pub_center/updateNodePublish.do" ,
    dataType:"json",
    data: data,
    async: false,
    success: function (msg) {
      if(publish=='0'){
        $("#"+nodeId).html("已发布");
      }else if(publish=='1'){
        $("#"+nodeId).html("未发布");
      }
      if(msg.msg=='success'){
        alert('修改成功！');
      }else{
        alert('参数错误，请刷新重试！');
      }

    },
    error: function (msg) {
      alert("系统异常！");
    }
  });
}
</script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
	<h1>${parent.name}(栏目) - <s:message code="list"/> <small>(<s:message code="totalElements" arguments="${fn:length(list)}"/>)</small></h1>
</div>
<div class="content">
	<div class="box box-primary">
		<div class="box-body table-responsive">
			<form id="searchForm" action="nodelist.do" method="get" class="form-inline ls-search">
				<div class="form-group">
				  <label for="search_CONTAIN_name"><s:message code="node.name"/></label>
				  <input class="form-control input-sm" type="text" id="search_CONTAIN_name" name="search_CONTAIN_name" value="${search_CONTAIN_name[0]}"/></label>
				</div>
				<div class="form-group">
				  <label for="search_CONTAIN_number"><s:message code="node.number"/></label>
				  <input class="form-control input-sm" type="text" id="search_CONTAIN_number" name="search_CONTAIN_number" value="${search_CONTAIN_number[0]}"/></label>
				</div>
				<%--<div class="form-group">--%>
				  <%--<label for="search_EQ_hidden_Boolean"><s:message code="node.hidden"/></label>--%>
			  	<%--<select class="form-control input-sm" id="search_EQ_hidden_Boolean" name="search_EQ_hidden_Boolean">--%>
			  		<%--<option value=""><s:message code="allSelect"/></option>--%>
			  		<%--<f:option value="true" selected="${search_EQ_hidden_Boolean[0]}"><s:message code="yes"/></f:option>--%>
			  		<%--<f:option value="false" selected="${search_EQ_hidden_Boolean[0]}"><s:message code="no"/></f:option>--%>
			  	<%--</select>--%>
				<%--</div>--%>
			  <button class="btn btn-default btn-sm" type="submit"><s:message code="search"/></button>
			  <f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="returnUrl" value="${returnUrl}"/>
			  <f:hidden name="showDescendants" value="${showDescendants}"/>
			</form>
			<form class="form-inline" action="nodebatch_update.do" method="post">
				<tags:search_params/>
				<f:hidden name="queryParentId" value="${queryParentId}"/>
                <f:hidden name="returnUrl" value="${returnUrl}"/>
				<f:hidden name="showDescendants" value="${showDescendants}"/>
				<div class="btn-toolbar ls-btn-bar" style="float: none">
                    <div class="btn-group">
                        <shiro:hasPermission name="core:generation:nodeHome">
                        <button class="btn btn-default"  type="button" onclick="$('#load').showLoading();location.href='generationNodeHome.do?queryParentId=${parent.id}&returnUrl=nodelist&showDescendants=true';">生成栏目页</button>
                        </shiro:hasPermission>
                    </div>
					<div class="btn-group">
                            <shiro:hasPermission name="core:pub_center:node:create">
                                <button class="btn btn-default" type="button" onclick="location.href='nodecreate.do?parentId=${parent.id}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}';"><s:message code="create"/></button>
                            </shiro:hasPermission>
					</div>
					<div class="btn-group">
						<shiro:hasPermission name="core:pub_center:batch_update">
						<button class="btn btn-default" type="submit"><s:message code="save"/></button>
						</shiro:hasPermission>
					</div>
					<div class="btn-group">
						<%--&lt;%&ndash;<shiro:hasPermission name="core:node:copy">&ndash;%&gt;--%>
						<%--&lt;%&ndash;<button class="btn btn-default" type="button" onclick="return optSingle('#copy_opt_');"><s:message code="copy"/></button>&ndash;%&gt;--%>
						<%--&lt;%&ndash;</shiro:hasPermission>&ndash;%&gt;--%>
						<%--<shiro:hasPermission name="core:node:edit">--%>
						<%--<button class="btn btn-default" type="button" onclick="return optSingle('#edit_opt_');"><s:message code="edit"/></button>--%>
						<%--</shiro:hasPermission>--%>
					  <%--<shiro:hasPermission name="core:node:move_form">--%>
					  <%--<button class="btn btn-default" type="button" onclick="return optMulti(this.form,'nodemove_form.do?queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstring}',true);"><s:message code="move"/></button>--%>
					  <%--</shiro:hasPermission>--%>
					  <%--<shiro:hasPermission name="core:node:merge_form">--%>
					  <%--<button class="btn btn-default" type="button" onclick="location.href='merge_form.do?parentId=${parent.id}&queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstring}';"><s:message code="merge"/></button>--%>
					  <%--</shiro:hasPermission>--%>
						<%--<shiro:hasPermission name="core:node:delete">--%>
						<%--<button class="btn btn-default" type="button" onclick="return optDelete(this.form);"><s:message code="delete"/></button>--%>
						<%--</shiro:hasPermission>--%>
					<%--</div>--%>
					<div class="btn-group">
						<shiro:hasPermission name="core:pub_center:batch_update">
					  <button class="btn btn-default" type="button" onclick="Cms.moveTop('ids');"><s:message code='moveTop'/></button>
					  <button class="btn btn-default" type="button" onclick="Cms.moveUp('ids');"><s:message code='moveUp'/></button>
					  <button class="btn btn-default" type="button" onclick="Cms.moveDown('ids');"><s:message code='moveDown'/></button>
					  <button class="btn btn-default" type="button" onclick="Cms.moveBottom('ids');"><s:message code='moveBottom'/></button>
					  </shiro:hasPermission>
					</div>
				</div>
				<table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
				  <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}" pageurl="nodelist.do?page_sort={0}&page_sort_dir={1}&queryParentId=${queryParentId}&showDescendants=${showDescendants}&${searchstringnosort}">
				  <tr class="ls_table_th">
				    <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
				    <%--<th width="240"><s:message code="operate"/></th>--%>
				    <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">ID</span></th>
				    <th class="ls-th-sort"><span class="ls-sort" pagesort="name"><s:message code="node.name"/></span></th>
				    <th class="ls-th-sort"><span class="ls-sort" pagesort="number"><s:message code="node.number"/></span></th>
				    <%--<th class="ls-th-sort"><span class="ls-sort" pagesort="nodeModel"><s:message code="node.model"/></span></th>--%>
                    <th class="ls-th-sort"><span class="ls-sort" pagesort="creationDate">创建时间</span></th>
				    <%--<th class="ls-th-sort"><span class="ls-sort" pagesort="views"><s:message code="node.views"/></span></th>--%>
				    <%--<th><s:message code="node.hidden"/></th>--%>
				    <%--<th><s:message code="node.html"/></th>--%>
				  </tr>
				  </thead>
				  <tbody>
				  <c:forEach var="bean" varStatus="status" items="${list}">
				  <tr beanid="${bean.id}">
				    <td><input type="checkbox" name="ids" value="${bean.id}"/></td>
				    <%--<td align="center">--%>
							<%--&lt;%&ndash;<shiro:hasPermission name="core:node:create">&ndash;%&gt;--%>
				      <%--&lt;%&ndash;<a id="createChild_opt_${bean.id}" href="nodecreate.do?parentId=${bean.id}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}" class="ls-opt"><s:message code="node.createChild"/></a>&ndash;%&gt;--%>
				      <%--&lt;%&ndash;</shiro:hasPermission>&ndash;%&gt;--%>
							<%--&lt;%&ndash;<shiro:hasPermission name="core:node:copy">&ndash;%&gt;--%>
				      <%--&lt;%&ndash;<a id="copy_opt_${bean.id}" href="nodecreate.do?cid=${bean.id}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}" class="ls-opt"<c:if test="${bean.parent==null}"> disabled="disabled"</c:if>><s:message code="copy"/></a>&ndash;%&gt;--%>
				      <%--&lt;%&ndash;</shiro:hasPermission>&ndash;%&gt;--%>
							<%--<shiro:hasPermission name="core:node:edit">--%>
				      <%--<a id="edit_opt_${bean.id}" href="nodeedit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}" class="ls-opt"><s:message code="edit"/></a>--%>
				      <%--</shiro:hasPermission>--%>
				      <%--&lt;%&ndash;<shiro:hasPermission name="core:node:move_form">&ndash;%&gt;--%>
				      <%--&lt;%&ndash;<a id="move_opt_${bean.id}" href="nodemove_form.do?ids=${bean.id}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}" class="ls-opt"<c:if test="${bean.parent==null}"> disabled="disabled"</c:if>><s:message code="move"/></a>&ndash;%&gt;--%>
				      <%--&lt;%&ndash;</shiro:hasPermission>&ndash;%&gt;--%>
							<%--<shiro:hasPermission name="core:node:delete">--%>
				      <%--<a href="nodedelete.do?ids=${bean.id}&queryParentId=${queryParentId}&returnUrl=${returnUrl}&showDescendants=${showDescendants}&${searchstring}" onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>--%>
				      <%--</shiro:hasPermission>--%>
				     <%--</td>--%>
				    <td><c:out value="${bean.id}"/><f:hidden name="id" value="${bean.id}"/></td>
				    <td>
                        <span style="padding-left:${showDescendants ? bean.treeLevel*12 : 0}px"><f:text class="form-control input-sm" name="name" value="${bean.name}" style="width:120px;"/></span>
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        <c:if test="${bean.nodeModel.flag eq 'news' or bean.nodeModel.flag eq 'activity_node'}">
                            <span id="${bean.id}">
                                <c:if test="${bean.publish eq '0'}">
                                    <c:out value="已发布" />
                                </c:if>
                                <c:if test="${bean.publish eq '1'}">
                                    <c:out value="未发布" />
                                </c:if></span>
                            <shiro:hasPermission name="core:node:updateNodePublish">
                                <a onclick="updateNodePublish('${bean.id}')" style="color: red">切换</a>
                            </shiro:hasPermission>
                        </c:if>
                    </td>
				    <td align="center"><f:text class="form-control input-sm" name="number" value="${bean.number}" style="width:120px;"/></td>
				    <%--<td align="left">${bean.nodeModel.name}<c:if test='${!empty bean.infoModel}'>, ${bean.infoModel.name}</c:if></td>--%>
				    <%--<td align="center"><f:text class="form-control input-sm" name="views" value="${bean.views}" style="width:60px;text-align:right;"/></td>--%>
				    <%--<td align="center"><f:checkbox name="hidden" value="${bean.hidden}"/></td>--%>
                    <td align="center"><fmt:formatDate value="${bean.creationDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				    <%--<td align="center">--%>
				      <%--<span style="<c:if test="${bean.htmlStatus eq '2' || bean.htmlStatus eq '3' || bean.htmlStatus eq '4'}">color:red;</c:if>"><s:message code="node.htmlStatus.${bean.htmlStatus}"/></span>--%>
				    <%--</td>--%>
				  </tr>
				  </c:forEach>
				  </tbody>
				</table>
				<c:if test="${fn:length(list) le 0}"> 
				<div class="ls-norecord"><s:message code="recordNotFound"/></div>
				</c:if>
			</form>
		</div>
	</div>
</div>
				

</form>
</body>
</html>